#!/bin/bash

# log_file=/dev/stdout
# log_file=/dev/stderr

#!/usr/bin/bash

NAME=wifi
SIS=sis-$NAME
HELP=help-$NAME
# logmsg="/home/gnu/sh/sis-logmsg"

# user_logmsg=badbro-test
# repo_logmsg=community
# pkg_logmsg=logmsg

# logmsg=$HOME/.local/$user_logmsg/$repo_logmsg/$pkg_logmsg/run.sh
alias logmsg='bbpm run logmsg'
logmsg_dir=`bbpm dir logmsg`


# conf:
# auto_connect='false'
auto_connect='true'




mkdir -p $logmsg_dir/log/
# log_file=~/.local/bad/log/badmsg.log
log_file=$logmsg_dir/log/logmsg.log

user_logmsg=badbro-test

# logmsg [-t D|DEBUG|I|INFO|S|SECURITY] <MSG>
# logmsg -t I "wifi downed!" -> "[2021-12-21 20:39:59:001] I wifi downed!"
# logmsg -t I wifi "wifi downed!" -> "[2021-12-21 20:39:59:001] I wifi: wifi downed!"
# logmsg -t I 'wifi get' "wifi downed!" -> "[2021-12-21 20:39:59:001] I wifi get: wifi downed!"

time=`date "+[%F %T]"`

type="I"
msg=${1}
key=${1}
if [[ '-t' == $key ]] ; then
	type=${2}	
	msg=${3}
fi

echo $time $type $msg  >> $log_file
